<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>水波纹</title>
    <style>
      * {
        margin: 0;
        padding: 0;
        box-sizing: border-box;
      }
      body {
        background-color: #161724;
        display: flex;
        justify-content: center;
        align-items: center;
        height: 100vh;
      }
      .button + .button {
        margin-left: 20px;
      }
      .buttons .button {
        display: inline-block;
        position: relative;
        padding: 10px 20px;
        border: none;
        border-radius: 5px;
        background-color: #212231;
        color: #fff;
        font-size: 16px;
        border-radius: 100px;
        font-size: 14px;
        font-weight: 400;
        background: linear-gradient(to left, #6a11cb, #2575fc);
        text-decoration: none;
        cursor: pointer;
        overflow: hidden;
        user-select: none;
        box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.5);
      }
      .buttons .two {
        background: linear-gradient(to left, #657423, #164e11);
      }
      .button .overlay {
        position: absolute;
        width: 400px;
        height: 400px;
        background-color: #fff;
        border-radius: 50%;
        opacity: 0.5;
        /* top: 0;
        left: 0; */
        transform: translate(-50%, -50%);
        animation: ripple 1s  infinite;
      }

      @keyframes ripple {
        0% {
          height: 0;
          width: 0;
          opacity: 0.5;
        }
        100% {
          width: 400px;
          height: 400px;
          opacity: 0;
        }
      }
    </style>
  </head>
  <body>
    <div class="buttons">
      <a class="button">
        <!-- <span class="overlay"></span> -->
        下一步
      </a>
      <a class="button two">
        <!-- <span class="overlay"></span> -->
        上一步
      </a>
    </div>
</body>
<script>
  const buttons = document.querySelectorAll('.button');
  buttons.forEach((button) => {
    button.addEventListener('click', (btn) => {        
        btn.preventDefault();
        const overlay = document.createElement('span');
        const y = btn.offsetY  + 'px'
        const x = btn.offsetX + 'px'
        overlay.style.left = x;
        overlay.style.top = y;
        overlay.classList.add('overlay');
        btn.target.appendChild(overlay);
        setTimeout(() => {
            overlay.remove();
        }, 500);
    });
  });
</script>
</html>
